package com.baitengsoft.patentapimonitor.common.utils;

import java.math.BigDecimal;

/**
 * 增长率工具类
 * @author Chen 2018/1/2
 */
public class IncreaseRateUtils {
    /**
     * 年增长率计算
     */
    public static BigDecimal getIncreaseRate(BigDecimal thisYearTotal ,BigDecimal lastYearTotal){
        if(lastYearTotal == null || lastYearTotal.compareTo(new BigDecimal(0)) == 0) return null;
        return thisYearTotal.subtract(lastYearTotal).multiply(new BigDecimal(100)).divide(lastYearTotal,2,BigDecimal.ROUND_HALF_DOWN);
    }
}
